﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BDPAutodetect.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace BDPAutodetect.Client
{
    /// <summary>
    /// StationView.xaml 的交互逻辑
    /// </summary>
    [ObservableObject]
    public partial class StationView : UserControl
    {
        /// <summary>
        /// 工位数据
        /// </summary>
        public MStationDetectDto StationData { get { return (MStationDetectDto)GetValue(StationDataProperty); } set { SetValue(StationDataProperty, value); } }
        /// <summary>
        /// 工位数据属性
        /// </summary>
        public static readonly DependencyProperty StationDataProperty = DependencyProperty.Register("StationData", typeof(MStationDetectDto), typeof(StationView), new UIPropertyMetadata(default));

        /// <summary>
        /// 指令
        /// </summary>
        public ICommand Command { get { return (ICommand)GetValue(CommandProperty); } set { SetValue(CommandProperty, value); } }
        /// <summary>
        /// 指令属性
        /// </summary>
        public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(StationView), new UIPropertyMetadata(default));

        /// <summary>
        /// 指令参数
        /// </summary>
        public object CommandParameter { get { return GetValue(CommandParameterProperty); } set { SetValue(CommandParameterProperty, value); } }
        /// <summary>
        /// 指令参数属性
        /// </summary>
        public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(object), typeof(StationView));

        /// <summary>
        /// 构造函数
        /// </summary>
        public StationView()
        {
            InitializeComponent();
            ((FrameworkElement)this.Content).DataContext = this;
        }

        /// <summary>
        /// 按钮点击执行命令事件
        /// </summary>
        /// <param name="argCommandType">按钮指令类型</param>
        [RelayCommand]
        public void ExecuteButton(ButtonCommandType argCommandType)
        {
            if (this.Command != null)
            {
                this.Command.Execute(argCommandType);
            }              
        }
    }
}
